<%@page import="com.billing.model.entity.Message"%>
<%@page import="java.util.List"%>
<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c"%>
<%@page isELIgnored="false" %>
<%
String path = request.getContextPath();
String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";

String startDate=request.getAttribute("startDate").toString();
String endDate=request.getAttribute("endDate").toString();
String status=request.getAttribute("status").toString();
%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html lang="en">
<head>
	<meta charset="utf-8">
	<title>消息管理列表</title>
	<meta name="viewport" content="width=device-width, initial-scale=1">
	<link id="bootstrap-style" href="<c:url value="/css/bootstrap.min.css"/>" rel="stylesheet">
	<link href="<c:url value="/css/bootstrap-responsive.min.css"/>" rel="stylesheet">
	<link id="base-style" href="<c:url value="/css/style.css"/>" rel="stylesheet">
	<link id="base-style-responsive" href="<c:url value="/css/style-responsive.css"/>" rel="stylesheet">
	<link href="<c:url value="/css/index.css"/>" rel="stylesheet">
	<link rel="shortcut icon" href="<c:url value="/img/favicon.ico"/>">
	<link href="<c:url value="/css/page.css"/>" rel="stylesheet">
	<link rel="stylesheet" type="text/css" href="<c:url value="/css/jquery.datetimepicker.css"/>"/>
	<link href="<c:url value="/css/but.css"/>" rel="stylesheet">
	<script src="<c:url value="/js/jquery-1.9.1.min.js"/>"></script>
	<script src="<c:url value="/js/jquery-migrate-1.0.0.min.js"/>"></script>
	<script type="text/javascript" src="<c:url value="/js/layer/layer.js"/>"></script>
	<script src="<c:url value="/js/laydate/laydate.js"/>"></script>
	<script src="<c:url value="/js/build/jquery.datetimepicker.full.js"/>"></script>
</head>
 <script type="text/javascript">
 function gotoPage(pageNum){
	 	var totalPage=jQuery("#totalPage").val();
		regexpdat=/^\d+$/;
		if(!regexpdat.test(pageNum)){
			alert("查询的页面必须为数字");
			return ;
		}
		if(1 > Number(pageNum) || Number(pageNum) > totalPage){
			alert("请求页面不在范围之内，请重新输入");
			return;
		}
		jQuery("#currentPage").val(pageNum);
		document.forms["frm"].submit();
	}
 
 function submitForm(){
	 var title=jQuery("#title").val();
	 title= encodeURI(encodeURI(title));
	 jQuery("#titletext").val(title);
	 document.forms["frm"].submit();
 }
function insertUser(id) {
     layer.open({
	   title: '排班设置',
       type: 2,
       area: ['500px', '350px'],
       fixed: false, //不固定
       maxmin: true,
       content: '<%=basePath%>shift/insertUser?id='+id
     });
 }
 
function add() {
	/* var url=$("#basePath").attr("value");
	 url +="message/addpage";
	 parent.$("#mainFrame").attr("src",url); */
    layer.open({
	  title: '新增消息',
      type: 2,
      area: ['850px', '686px'],
      fixed: false, //不固定
      maxmin: false,
      content: '<%=basePath%>message/addpage'
    }); 
}
//修改
function upd(id) {
	/* var url=$("#basePath").attr("value");
	 url +="message/addpage";
	 parent.$("#mainFrame").attr("src",url); */
    layer.open({
	  title: '修改消息',
      type: 2,
      area: ['850px', '686px'],
      fixed: false, //不固定
      maxmin: false,
      content: '<%=basePath%>message/updatedapage?id='+id+'&type=1'
    }); 
}
//查看
function sel(id) {
	/* var url=$("#basePath").attr("value");
	 url +="message/addpage";
	 parent.$("#mainFrame").attr("src",url); */
    layer.open({
	  title: '查看消息',
      type: 2,
      area: ['850px', '686px'],
      fixed: false, //不固定
      maxmin: false,
      content: '<%=basePath%>message/updatedapage?id='+id+'&type=2'
    }); 
}
 
 
function del(id) {
	if(confirm("确定删除消息信息吗?")){
		jQuery.ajax({
			url:'<%=basePath%>message/modifyStateMess?id='+id,
			type:"post",
			dataType:"json",
			success:function(json){
			}
		});
		alert("可在回收站查看！！！");
		window.location.reload();
	}
 }
 
 //审核
 function examine(id,termstate){
	 if(termstate == 0){
		 alert("已过期，不能审核！！");
	 }else{
		 jQuery.ajax({
				url:'<%=basePath%>message/examineMessage?id='+id,
				type:"post",
				dataType:"json",
				success:function(json){
				}
			});
		 	alert("已提交审核！！！");
			window.location.reload();
	 }
 }

 $(function(){
	 laydate.render({
		  elem: '#startDate'
		  ,type: 'date'
		  ,format: 'yyyyMMdd'
		});
	 laydate.render({
		  elem: '#endDate'
		  ,type: 'date'
		  ,format: 'yyyyMMdd'
		});
 });
 
 function resetme(){
	 document.frm.reset();
	 $("#title").val("");
	 $("#cont  option[value=''] ").attr("selected",true)
	 $("#startDate").val("");
	 $("#endDate").val("");
	 $("#status  option[value=''] ").attr("selected",true)
 }
 
 function release(){
	 alert(".......");
 }
 </script>
<body>
<div class="container-fluid-full">
	<div class="row-fluid">
		<div id="basePath" value="<%=basePath%>" style="display:none;"></div>
		<form name="frm" id="frm" method="get" action="<%=basePath%>message/mainpage">
				<input type="hidden" id="totalPage" name="totalPage" value="${totalPage}"> 
				<input type="hidden" id="currentPage" name="currentPage" value="${currentPage}"> 
				<input type="hidden" id="titletext" name="titletext" value="${title}"> 
				<div id="content" class="span10" >
					<div class="row-fluid content-search">
						<div>
							<span>标题：</span>
							<input type="text" id="title" name="title" value="${title}">
						</div>
						<div>
							<span>类型：</span>
							<select name="cont" id="cont" class="buildselect">
								<option value="">请选择</option>
								<c:forEach items="${contentlist }" var="a">
									<option value="${a.id }"  ${a.id==cont?'selected':''}>${a.name }</option>
								</c:forEach> 
							</select>
						</div>
						<div> 
							<span>创建时间：</span>
							<!-- <input type="date" id="startDate" name="startDate" style="width:30%;" value=""> -->
							<input type="text" class="demo-input" value="<%=startDate %>" id="startDate" name="startDate">
							<span>--</span>
							<input type="text" class="demo-input" value="<%=endDate %>" id="endDate" name="endDate">
							<!-- <input type="date" id="endDate" name="endDate" style="width:30%;" value=""> -->
						</div> 
						<div>
							<span>审核状态：</span>
							<select id="status" name="status" style="width: 100px">
									 <option value=""  <%if("".equals(status)){ %>selected<%}%>>请选择</option>
								 	 <option value="0" <%if("0".equals(status)){ %>selected<%}%>>审核中</option>
								 	 <option value="1" <%if("1".equals(status)){ %>selected<%}%>>已审核</option>
								 	 <option value="2" <%if("2".equals(status)){ %>selected<%}%>>未审核</option>
							</select>
						</div>&nbsp;&nbsp;&nbsp;&nbsp;
						<!-- <div>
							<span>期限状态：</span>
							<select id="termstate" name="termstate" style="width: 100px">
								 	 <option value="">请选择</option>
								 	 <option value="0" >已过期</option>
								 	 <option value="1" >未到期</option>
							</select>
						</div>&nbsp;&nbsp;&nbsp;&nbsp; -->	
						<div>
							<button class="but" type="button" id="select" onclick="submitForm();">查询</button>&nbsp;&nbsp;
							<button class="but" type="button" id="select" onclick="add();">添加</button>&nbsp;&nbsp;
							<button class="but" type="button" id="select" onclick="resetme();">重置</button>
						</div>
					</div>
					<div class="row-fluid content-table">
						<table class="table table-striped table-bordered bootstrap-datatable">
						  <thead>
							  <tr>
							  	  <!-- <th>状态</th> -->
							  	  <th>标题</th>
								  <th>摘要</th>
								  <th>撰写人</th>
								  <!-- <th>类型</th> -->
								  <th>录入时间</th>
								  <!-- <th>期限状态</th> -->
								  <th>审核状态</th>
								  <th>操作</th>
							  </tr>
						  </thead>   
						  <tbody>
						  	<c:forEach items="${list }" var="a">
								<tr>
									<%-- <td>
										<c:if test="${a.releasestate == 0}"><font color="red">已发布</font></c:if>	
										<c:if test="${a.releasestate == 1}">未发布</c:if>	
										<c:if test="${a.releasestate == 2}">已收回</c:if>
									</td> --%>
									<td>${a.title }</td>
									<td>${a.introduction }</td>
									<td>${a.uname }</td>
									<%-- <td>${a.cont.name }</td> --%>
									<td>${a.addeddateString }</td>
									<%-- <td>
										<c:if test="${a.termstate == 0}"><font color="red">已过期</font></c:if>	
										<c:if test="${a.termstate == 1}">未到期</c:if>	
									</td> --%>
									<td>
										<c:if test="${a.status == 0}">审核中</c:if>	
										<c:if test="${a.status == 1}">已审核</c:if>
										<c:if test="${a.status == 2}">未审核</c:if>
									</td>
									<td>
										<a href="#" onclick="sel(${a.id});">查看</a>
										<c:if test="${a.status != 0}">
											<c:if test="${a.releasestate != 0}">
												<a href="#" onclick="del(${a.id});">删除</a>
											</c:if>
											<c:if test="${a.status != 1}">
												<a href="#" onclick="upd(${a.id});">修改</a>
												<%-- <c:if test="${a.termstate != 0}"> --%>
													<a href="#" onclick="examine(${a.id});">审核</a>
												<%-- </c:if> --%>
											</c:if>
										</c:if>
										<%-- <c:if test="${a.status == 1}">
											<c:if test="${a.termstate == 1}">
												<c:if test="${a.releasestate == 1}">
													<a href="#" onclick="release(${a.id});"><font color="red">发布</font></a>
												</c:if>
											</c:if>
										</c:if> --%>
									</td>
								</tr>
						  	</c:forEach>
						  </tbody>
					  </table>            
					</div>	
					<div id="app">
				    <div>
				    
				      <div class="page"  v-show="show">
				      	<div class="span">
						</div>
				        <div class="pagelist">
				        
				          <span class="jump" :class="{disabled:pstart}" onClick="gotoPage(1);">首页</span>
				          <span class="jump" :class="{disabled:pstart}" onClick="gotoPage(${currentPage}-1);return false;">上一页</span>
				          <span v-show="current_page>5" class="jump" onClick="gotoPage(1);">1</span>
				          <span class="ellipsis"  v-show="efont">...</span>
				          <span class="jump" v-for="num in indexs" :class="{bgprimary:current_page==num}" onClick="gotoPage(jQuery(this).text());">{{num}}</span>
				          <span class="ellipsis"  v-show="ebehind">...</span>
				
				          <span :class="{disabled:pend}" class="jump" onClick="gotoPage(${currentPage}+1);return false;">下一页</span>
				          <span v-show="current_page<pages-4" class="jump" onClick="gotoPage(${totalPage})">{{pages}}</span>
				
				          <span class="jumppoint">跳转到：</span>
				          <span class="jumpinp"><input type="text" v-model="changePage" name="pageNum" id="pageNum" value=""/></span>
				          <span class="jump gobtn" onClick="gotoPage(jQuery('#pageNum').val())">GO</span>
				        </div>
				      </div>
				    </div>
				  </div>
				</div>
		</form>
	</div>
</div>
			<script src="<c:url value="/js/vue.js"/>"></script>
			<script src="<c:url value="/js/vueClick.js"/>"></script>
</body>
</html>
